package com.example.demo.service.impl;

import com.example.demo.mapper.OrderMapper;
import com.example.demo.po.Order;
import com.example.demo.service.OrderService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class OrderServiceImpl implements OrderService {

    @Resource
    private OrderMapper orderMapper;

    @Override
    public Order getById(Long id) {
        return orderMapper.selectById(id);
    }

    @Override
    public List<Order> getByUserId(Long userId) {
        return orderMapper.selectByUserId(userId);
    }

    @Override
    public List<Order> getAll() {
        return orderMapper.selectAll();
    }

    @Override
    public boolean create(Order order) {
        return orderMapper.insert(order) > 0;
    }

    @Override
    public boolean update(Order order) {
        return orderMapper.update(order) > 0;
    }

    @Override
    public boolean deleteById(Long id) {
        return orderMapper.deleteById(id) > 0;
    }
}